<?php

function sortDistance ($distanceArray) {
	foreach ($distanceArray as $group => $settings) {
		$x = $distanceArray[$group]["distance"];

		foreach ($distanceArray as $group2 => $settings2) {
			$y = $distanceArray[$group2]["distance"];

			if ($distanceArray[$group]["distance"] < $distanceArray[$group2]["distance"]) {
				$holdDistance = $distanceArray[$group]["distance"];
				$holdTo = $distanceArray[$group]["to"];

				$distanceArray[$group]["distance"] = $distanceArray[$group2]["distance"];
				$distanceArray[$group]["to"] = $distanceArray[$group2]["to"];

				$distanceArray[$group2]["distance"] = $holdDistance;
				$distanceArray[$group2]["to"] = $holdTo;
			}
		}
	}

	return array_values($distanceArray);
}

?>